package com.mtbu.bean.base;
import java.util.*;
import java.text.SimpleDateFormat;
import org.json.JSONObject;
import my.json.core.JsonAble;
public abstract class SysFuncMapBase implements JsonAble {
    private Map<String, Object> dirtyProperties = new HashMap<String, Object>();
    //ID
    private int id = 0;
    //类型 0用户 1角色
    private int type = 0;
    //用户或角色名
    private String uRName = "";
    //所属功能ID
    private int fID = 0;
    public int getId(){
        return this.id;
    }
    public void setId(int id){
        this.id = id;
    }
    public int getType(){
        return this.type;
    }
    public void setType(int type){
        this.type = type;
        dirtyProperties.put("type", type);
    }
    public String getURName(){
        return this.uRName;
    }
    public void setURName(String uRName){
        this.uRName = uRName;
        dirtyProperties.put("uRName", uRName);
    }
    public int getFID(){
        return this.fID;
    }
    public void setFID(int fID){
        this.fID = fID;
        dirtyProperties.put("fID", fID);
    }
    public Map<String, Object> getDirtyProperties() {
        return this.dirtyProperties;
    }
    public JSONObject toJSON() throws Exception {
        JSONObject json = new JSONObject();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        json.put("id", this.getId());
        json.put("type", this.getType());
        if(uRName!=null){
           json.put("uRName",this.getURName());
        }
        json.put("fID", this.getFID());
        return json;
    }
    public void fromJSON(JSONObject json) throws Exception {
        if(json==null) return;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try{
            if(json.get("id") != null){
                this.setId(Integer.parseInt(json.get("id")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("type") != null){
                this.setType(Integer.parseInt(json.get("type")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("uRName") != null){
                this.setURName(json.get("uRName")+"");
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("fID") != null){
                this.setFID(Integer.parseInt(json.get("fID")+""));
            }
        }catch(Exception ex){
        }
    }
    public void fromMap(Map<String, String> json) throws Exception {
        if(json==null) return;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            if(json.containsKey("id".toLowerCase())){
                this.setId(Integer.parseInt(json.get("id".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("type".toLowerCase())){
                this.setType(Integer.parseInt(json.get("type".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("uRName".toLowerCase())){
                this.setURName(json.get("uRName".toLowerCase())+"");
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("fID".toLowerCase())){
                this.setFID(Integer.parseInt(json.get("fID".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
    }
}
